package net.wanderinghorse.jsonmessage;

/**
 * Models the following Request.post() callback functions specified by
 * the JavaScript side of the API:
 *
 * beforePost(), afterPost(), onError()
 *
 * This class SHOULD be an inner class of Request, but Java applies
 * restrictions on the instantiation of abstract inner classes which hinder
 * us here.
 *
 * Implementations are generally not intended to have any state which affects
 * their results from call to call, but there are exceptions. For example,
 * a beforePost()/afterPost() pair might increment/decrement a counter to
 * allow the app to know how many requests are pending.
 */
public interface CallbackRequestOpt {
    /**
     * See the JavaScript API for full details.
     * @param r The request the callback is to act on behalf of.
     * @param o The connection options associated with this request.
     * @throws Exception Implementations may throw arbitrary exceptions.
    */
    public void invoke( Request r, PostOptions o ) throws Exception;
}
